<style lang="stylus" type="text/stylus">
  @import "css/editComponent.styl"
</style>

<template>
  <div class="edit-component-con">
    <div class="status-block block-com">
      <div class="status-title block-title-com">目前环节</div>
      <div class="status-con block-con-com">
        <div class="status">
          <span>{{applyStatusOnOffStr(editComponentData.applyStatus,processInstance)}}</span>
          <span v-if="applyStatusStr(editComponentData.applyStatus,false,processInstance)">&nbsp;-&nbsp;{{applyStatusStr(editComponentData.applyStatus,false,processInstance)}}</span>
        </div>
        <div class="status-describe describe-com">{{applyStatusDescribe}}</div>
        <div class="status-msg">
          <div>
            <span>所申报政策</span>
            <span>{{editComponentData.policyShortTitle}}</span>
          </div>
          <div>
            <span>申请创建时间</span>
            <span>{{ (editComponentData.applyAt) | fmtDate }}</span>
          </div>
        </div>
      </div>
    </div>

    <div class="card block-com" v-if="activities.length > 1">
      <p class="block-title-com">线下审核记录</p>
      <div class="block-con-com">
        <div class="describe-com">本申请已经进入线下审核阶段,因此,你可以查看它已经历的线下审核各环节细节。</div>
        <div class="success" @click="findExaminRecord(applyId)">查看线下审核记录</div>
      </div>
    </div>

    <div class="to-do-block card block-com" v-if="isToDo">
      <p class="to-do-title block-title-com">标记企业</p>
      <div class="to-do-con block-con-com">
        <div class="describe-com">点击以下3种标记,可以帮助你对申请进行初步的筛选。标记可以随时更改,且不会被企业察觉,只是一种整理申请的辅助手段。</div>
        <Select @on-change="toDoChange" class="to-do-select" v-model="toDoModel">
          <Option v-for="item in toDo" :value="item.id" :key="item.id">{{item.name}}</Option>
        </Select>
      </div>
    </div>

    <div v-if="isAppoint && !processInstance&& _SERVER !='123'" class="block-com card appoint-block">
      <p class="appoint-title block-title-com">预约办理时间</p>
      <div class="appoint-con block-con-com">
        <div class="describe describe-com">{{appointDescribe}}</div>
        <DatePicker v-model="appointDateValue" confirm :clearable="false"
                    @on-ok="SetScheduleTime()" type="datetime"
                    :format="`yyyy/MM/dd，HH:mm`"
                    placeholder="未设置办理时间" style="width: 100%"></DatePicker>
        <br><br>
        <div class="describe-com">设置了政府对接人之后,企业可以获得其联系方式。</div>
        <Select :transfer="true" @on-change="SetScheduleTime" class="to-do-select" v-model="scheduleContactValue">
          <Option v-for="item in scheduleContactList" :value="item.id" :key="item.id">{{item.name}}</Option>
        </Select>
      </div>
    </div>

    <div class="card block-com" v-if="myActivity && myActivity.activityForms.length">
      <p class="block-title-com">审核细则</p>
      <div class="block-con-com activity-forms">
        <ul>
          <template>
            <li class="activity-forms-items" v-for="(forms,formsIndex) in myActivity.activityForms">
              <div class="block-com-title">{{forms.title}}</div>
              <div class="con" v-if="forms.formType == 0">
                <Select style="margin-bottom: 10px;" @on-change="activityFormsChange1($event,forms.id,forms.memo)"
                        :clearable="true"
                        v-model="forms.value">
                  <Option v-for="item in forms.checkItems" :value="item.id.toString()" :key="item.id">{{ item.title }}
                  </Option>
                </Select>
                <div @click="memoApply('备注',forms,forms.memo)" class="block-com-textarea">{{forms.memo}}<span
                  v-if="!forms.memo" class="memo">备注</span></div>
              </div>
              <div class="con" v-if="forms.formType == 2">
                <div @click="memoApply(forms.title,forms,forms.value)" class="block-com-textarea">{{forms.value}}<span
                  v-if="!forms.value" class="memo">请输入</span></div>
              </div>
            </li>
          </template>
        </ul>
      </div>
    </div>

    <div class="card block-com uploadfile" v-if="myActivity && requisitionObj != null">
      <div class="block-title-com">项目申报审核表</div>
      <div class="block-con-com">
        <a :href="requisitionObj.fileInfo.filePath" target="_blank">{{requisitionObj.fileInfo.fileName}}</a>
      </div>
    </div>

    <div class="card block-com uploadfile" v-if="myActivity">
      <div class="block-title-com">审核细则配套附件</div>
      <div class="block-con-com">
        <ul class="uploadfile-ul" v-if="myActivity.files.length">
          <li class="uploadfile-items" v-for="(files,filesIndex) in myActivity.files" :key="filesIndex">
            <div class="icon-tools">
              <i class="iconfont-files iconfont" :class="'icon-' + filesType(files.suffix)"></i>
              <div class="tools">
                <a target="_blank" :href="files.filePath" class="download btn-com">
                  <Icon type="android-download"></Icon>
                </a>
                <div @click="deleteFile(files.id)" class="delete btn-com">
                  <Icon type="android-delete"></Icon>
                </div>
              </div>
            </div>
            <p>{{files.fileName}}</p>
          </li>
        </ul>
        <!--accept=".docx,.doc,.zip,.xlsx,.pdf"-->
        <!--:format="['docx','doc','zip','xlsx','pdf']"-->
        <Upload :show-upload-list="false"
                :with-credentials="!0"
                :before-upload="beforeUpload"
                :action="uploadUrl"
                :data="{activityId:myActivitieID,applyId:applyId}"
                :on-success="uploadFiles">
          <Button type="primary" icon="ios-cloud-upload-outline" long>上传文件</Button>
        </Upload>
      </div>
    </div>

    <div class="card block-com edit-block" v-if="nextWork">
      <p class="edit-title block-title-com">本环节结案</p>
      <div class="edit-con block-con-com">
        <template v-if="isToDo">
          <div class="success" style="margin-bottom: 10px;" @click="editApplyStatus({action:'approveOnline'})">
            <!-- {{_SERVER==123||_SERVER==203?'通过网上预受理':'预约线下办理'}} -->
            预约线下办理
          </div>
          <div class="error" @click="rejectApply('rejectOnline','驳回线上申请')">驳回线上申请</div>
        </template>

        <template v-if="isAppoint && !processInstance">
          <!-- <div v-if="_SERVER==139 || _SERVER==120 || _SERVER==118" class="error" style="margin-bottom: 10px;" @click="printReceipt()">打印回执单 -->
            <div class="error" style="margin-bottom: 10px;" @click="printReceipt()">打印回执单
          </div>
          <div class="success" style="margin-bottom: 10px;" @click="startWorkflow()">进入线下审核
          </div>
          <div class="error" @click="rejectApply('rejectOffline','驳回申请')">驳回申请</div>
        </template>

        <template v-if="isAdmin && activities.length == 1">
          <div class="success" @click="endActivity(1)">开始线下审核流程</div>
        </template>

        <template v-if="myWork && activities.length == 2">
          <div style="margin-bottom: 10px;" class="success" @click="endActivity(1)">本环节通过</div>
          <div class="error" @click="endActivity(0)">本环节不通过</div>
        </template>

        <template v-if="isAdmin && activities.length==3">
          <div class="success" style="margin-bottom: 10px;"
               @click="endActivity(1)">最终结案：确认拨款
          </div>
          <div class="error" @click="endActivity(0)">最终结案：拒绝拨款</div>
        </template>

      </div>
    </div>

    <div class="card block-com edit-block" v-if="isAdmin">
      <p class="edit-title block-title-com">管理员操作</p>
      <div class="edit-con block-con-com">

        <template v-if="isToDo||isAppoint">
          <div class="describe describe-com">“强制中断”将会使这个申请作废,无法复原,请谨慎操作。</div>
          <div class="error" @click="rejectApply('terminate','强制中断')">强制中断</div>
          <br>
        </template>

        <template v-if="!BLOCKCOMPANY">
          <div class="describe describe-com">如果你选择拉黑这个企业,那么此企业所有进行中的申请都将被强制中断。</div>
          <div class="error" @click="companyBlock"><span
            class="block-company">拉黑“{{editComponentData.companyName}}”</span></div>
        </template>
        <template v-if="BLOCKCOMPANY">
          <div class="describe describe-com">如果你把这个企业从黑名单中移除,那么该企业的所有申请都将复原到相应政策的申请列表中。</div>
          <div class="success" @click="companyUnBlock">
            <span class="block-company">与“{{editComponentData.companyName}}”重修旧好</span>
          </div>
        </template>
      </div>
    </div>

    <Modal
      @on-cancel="closeReject()"
      v-model="rejectObj.rejectActive"
      :title="rejectObj.title">
      <Input :maxlength="5000" type="textarea" :autosize="{minRows: 5,maxRows: 8}" autofocus="autofocus"
             placeholder="请输入..."
             v-model="rejectObj.rejectApplyValue"></Input>
      <div slot="footer">
        <Button @click="closeReject()" type="text">取消</Button>
        <Button type="primary" @click="subReject()" size="large">提交</Button>
      </div>
    </Modal>

    <div class="read-process-record" @click="readProcessRecordActive = false" v-if="readProcessRecordActive">
      <div class="read-process-record-con" @click.stop>
        <VuePerfectScrollbar class="read-process-record-con-ps">
          <div class="read-process-record-con-flex">
            <div v-if="activities01.length" class="process-child" @click.stop
                 v-for="record in activities01" :key="record.id">
              <div class="process-child-con">
                <div class="process-title">{{record.name}}</div>
                <div class="precess-top">
                  <p><span class="marking">审核主体</span><span class="text">{{record.handler.fullName}}</span></p>
                  <p>
                    <span class="marking">环节状态</span>
                    <span
                      :class="[record.ended?record.result==1?'pass':'unpass':'inprogress']">{{record.ended?record.result==1?'通过':'不通过':'进行中'}}</span>
                    <span v-if="record.ended" class="text">（{{record.operator.fullName}}）</span>
                  </p>
                  <p><span class="marking">时长</span><span class="text">{{getTime(record.startAt,1)}}&nbsp;至&nbsp;{{record.ended?getTime(record.endAt,1):'今日'}}({{howDays(record.startAt,(record.ended?record.endAt:Number(new Date())))}})</span>
                  </p>
                </div>
                <div class="process-activity-forms" v-if="record.activityForms.length">
                  <ul>
                    <li v-if="forms.value||forms.memo" class="process-activity-forms-items"
                        v-for="forms in record.activityForms" :key="forms.id">
                      <p v-if="forms.value">
                        <span>{{forms.title}}：</span>
                        <span class="value" v-if="forms.formType == 0 && forms.value">{{(forms.checkItems.find(v=>v.id==forms.value)).title}}</span>
                        <span class="value" v-if="forms.formType != 0">{{forms.value}}</span>
                      </p>
                      <p class="process-memo" v-if="forms.formType==0 && forms.memo">备注：<span
                        class="value">{{forms.memo}}</span></p>
                    </li>
                  </ul>
                </div>
                <div class="process-activity-files" v-if="record.files.length">
                  <ul>
                    <li class="process-activity-files-items" v-for="files in record.files" :key="files.id">
                      <div class="icon-tools">
                        <i class="iconfont-files iconfont" :class="'icon-' + filesType(files.suffix)"></i>
                        <div class="tools">
                          <a target="_blank" :href="files.filePath" class="download btn-com">
                            <Icon type="android-download"></Icon>
                          </a>
                        </div>
                      </div>
                      <p>{{files.fileName}}</p>
                    </li>
                  </ul>
                </div>
                <div v-if="btnRefresh(record.ended)" class="btn-refresh" @click="refreshProcess(record.id)">
                  <span>重置环节</span>
                </div>
              </div>
            </div>
          </div>
        </VuePerfectScrollbar>
      </div>
      <!-- <div class="addMeeting" v-if="activities.length == 3 && (_SERVER==139 || _SERVER==120)" @click.stop="addMeetList">
        <span>上会表</span>
      </div> -->
    </div>
  </div>
</template>

<script type="text/ecmascript-6">

  export default {
    name      : 'EditComponent',
    data() {
      return {
        BLOCKCOMPANY: this.block.block,
        applyId     : this.editComponentData.id,
        toDo        : [
          {id: 21, name: '未处理'},
          {id: 22, name: '感兴趣'},
          {id: 23, name: '不考虑'},
        ],
        toDoModel   : this.editComponentData.applyStatus,

        rejectObj: {
          title           : '',
          action          : '',
          rejectActive    : false,
          rejectApplyValue: '',
          forms           : ''
        },

        appointDateValue    : '',
        scheduleContactList : [],
        scheduleContactValue: '',


        activityFormId: '',

        activityFormsValue2: '',

        readProcessRecordActive: false,

        uploadUrl: this._URL_v2 + '/workflow/uploadFile',

        addMeetUrl: '',  // 上会表下载地址
        addMeetListId: '',
        isShowBtn: true, // 打印回执单
        requisitionObj: null
      }
    },
    props     : ['editComponentData', 'block'],
    computed  : {
      isAdmin() {
        return this.$store.state.userMsg && this.$store.state.userMsg.admin
      },

      getRouteQuery() {
        return Object.assign({handlerId: this.$store.state.userMsg.position.id}, this.$route.query)
      },

      myWork() {
        let id
        this.activities.forEach(element => {
          if(element.name == "未开始"){
            id = element.handler.id
          } else if(element.name == "审核完毕"){
            id = element.handler.id
          } else if(element.name == null){
            for (let v of element.children) {
              if (v.handler.id == this.getPosition.id && !v.ended) {
                id = v.handler.id
              }
            }
          }
        });
        return id
      },

      myActivitieID() {
        let id = null
        if (this.activities.length == 2) {
          for (let v of this.activities[1].children) {
            if (v.handler.id == this.getPosition.id && !v.ended) {
              id = v.id
              break;
            }
          }
        }
        return id
      },


      isDone() {
        let done = false
        if (this.myWork && this.activities.length > 1) {
          for (let v of this.activities[1].children) {
            if (v.handler.id == this.getPosition.id) {
              if (!v.ended) {
                done = false
                break;
              } else {
                done = true
              }
            }
          }
        }
        return done
      },

      nextWork() {
        if (this.isOver || this.editComponentData.applyStatus == 49) {
          return false
        }
        if (this.activities.length == 2) {
          return this.myWork && !this.isDone
        } else if (this.activities.length == 3) {
          if (this.isAdmin) {
            return !0
          } else {
            return false
          }
        } else if (this.activities.length == 1) {
          if (this.isAdmin) {
            return !0
          } else {
            return false
          }
        } else {
          return this.isToDo || this.isAppoint
        }
      },

      myActivity() {
        let obj = null
        if (this.activities.length == 2) {
          for (let v of this.activities[1].children) {
            if (v.handler.id == this.getPosition.id && !v.ended) {
              obj = v
              break;
            }
          }
        }
        if (this.editComponentData.applyStatus == 49) {
          obj = null
        }
        return obj
      },

      getPosition() {
        return this.$store.state.userMsg.position
      },
      isToDo() {
        return [20, 21, 22, 23].includes(this.editComponentData.applyStatus);
      },
      isAppoint() {
        return [30, 31].includes(this.editComponentData.applyStatus);
      },
      isOver() {
        return [38, 39].includes(this.editComponentData.applyStatus);
      },
      processInstance() {
        return this.editComponentData.processInstance
      },
      activities() {
        return this.processInstance ? this.processInstance.activities : []
      },
      activities01() {
        return this.activities[1].children ? this.activities[1].children : this.activities[2].children
      },
      applyStatusDescribe() {
        let describe = '';
        if (this.isToDo) {
          describe = '阅读企业提交的线上申请，初步判断企业是否具备申报资金的条件，以此决定是否约见企业携带全部材料前来办理线下审核。'
        } else if (this.isAppoint && !this.processInstance) {
          describe = '已确定预约企业前往政府办理业务，系统已将具体材料清单发送至企业。';
        } else if (this.editComponentData.applyStatus == 29) {
          describe = `驳回理由：${this.editComponentData.reason}（管理员：${this.editComponentData.lastUpdateUser}）`;
        } else if (this.editComponentData.applyStatus == 49) {
          describe = `中断原因：${this.editComponentData.reason}（管理员：${this.editComponentData.lastUpdateUser}）`;
        } else if (this.editComponentData.applyStatus == 38) {
          describe = '本申请已完成全部流程，已确认拨款'
        } else if (this.editComponentData.applyStatus == 39) {
          describe = `本申请未通过线下审核，具体原因请查询线下审核记录`
        } else if (this.editComponentData.applyStatus == 42) {
          describe = `中断原因：拉黑企业（管理员：${this.editComponentData.lastUpdateUser}）`
        } else if (this.processInstance) {
          if (this.activities.length == 1) {
            describe = '考虑到线下审核有严格的时间限制，通过了线上审核验材料阶段的申请并不会自动开始线下审核环节，需要管理员在实际情况准备就绪之后手动开启。'
          } else if (this.activities.length == 2) {
            describe = `各环节审核主体根据各环节具体要求进行审核。`
          } else {
            describe = `各环节审核已经完毕，请管理员根据审核记录做出最终的结案。`
          }
        }
        return describe;
      },
      appointDescribe() {
        let describe = '';
        if (this.editComponentData.applyStatus == 30) {
          describe = '在设置了具体预约时间之后，该预约会自动展示到你与企业各自的日程安排之中。'
        } else if (this.editComponentData.applyStatus == 31) {
          let appointment = this.editComponentData.appointment,
              dateNow     = Number(new Date()),
              time        = Number(new Date(this.appointDateValue));
          if (time > dateNow) {
            describe = '你已经设置了办理时间，App将会提醒企业准时前来办理。你随时可以修改或清除这个时间。'
          } else {
            describe = '预约时间已经过去了。如果你已经与企业见面，那么你随时可以在此给出最终申请结果；如果时间安排有变，还没有与企业见面，那么请更改预约时间。'
          }
        }
        return describe
      },
      appointmentMsg() {
        return this.editComponentData.appointment ? this.editComponentData.appointment : ''
      },
      checkForm() {
        return this.rejectObj.rejectApplyValue ? false : 'disabled'
      }
    },
    methods   : {
      getScheduleContactList() {
        this.ajaxData({
          type: 'get',
          url : '/schedule/contact/list'
        }, (res, all) => {
          if (all.code == 0) {
            this.scheduleContactList = res;
            if (this.$store.state.userMsg.loginName == 'fcadmin') {
              this.scheduleContactList.push({
                id  : 194,
                name: this.$store.state.userMsg.name
              })
            }
          }
        })
      },
      editApplyStatus(obj) {
        let objdata = obj.data || {};
        this.ajaxData({
          type: 'post',
          url : `/sepcialApply/${this.applyId}/${obj.action}`,
          // url : '/specialApply/'+this.applyId+'/'+obj.action,
          data: objdata
        }, (res, all) => {
          this.closeReject()
          if (obj.action == 'approveOnline') {
            this.getScheduleContactList()
          }
          this.$Message.info('提交成功');
          this.$emit('componentConEditPs')
        })
      },
      toDoChange(status) {
        this.editApplyStatus({
          action: this.applyStatusStr(status, true)
        })
      },
      rejectApply(obj, title) {
        this.rejectObj.rejectActive = true
        this.rejectObj.action       = obj
        this.rejectObj.title        = title
      },
      memoApply(title, forms, value) {
        this.rejectObj.rejectActive     = true
        this.rejectObj.title            = title
        this.rejectObj.rejectApplyValue = value
        this.rejectObj.forms            = forms
      },
      subReject() {
        if (!this.processInstance) {
          this.editApplyStatus({
            data  : {
              reason: this.rejectObj.rejectApplyValue
            },
            action: this.rejectObj.action
          })
        } else if (this.rejectObj.action == 'terminate' && this.processInstance) {
          this.ajaxData({
            type: 'post',
            url : `/workflow/terminateApply`,
            data: {
              applyId: this.applyId,
              reason : this.rejectObj.rejectApplyValue
            }
          }, (res, all) => {
            this.closeReject()
            this.$Message.info('提交成功');
            this.$emit('componentConEditPs')
          })
        } else {
          if (this.rejectObj.forms.formType == 0) {
            this.activityFormsChange1(this.rejectObj.forms.value, this.rejectObj.forms.id, this.rejectObj.rejectApplyValue)
          } else {
            this.activityFormsChange1(this.rejectObj.rejectApplyValue, this.rejectObj.forms.id)
          }
        }
      },
      closeReject() {
        this.rejectObj.title            = ''
        this.rejectObj.action           = ''
        this.rejectObj.rejectActive     = false
        this.rejectObj.rejectApplyValue = ''
        this.rejectObj.forms            = ''
      },
      // 进入线下审核
      startWorkflow() {
        // this.ajaxData({type: 'post', url: `/workflow/start?applyId=${this.applyId}`}, (res, all) => {
        //   this.$emit('goBack')
        // })
      },
      // 打印回执单
      printReceipt(){
        this.isShowBtn = false;
        this.ajaxData({
          type:'get',
          url:'/apply/printReceipt',
          data:{
            applyId: this.applyId
          }
        },res=>{
          window.open(res.fileUrl,"_blank")
        })
      },

      endActivity(action) {
        let activityId;
        if (this.myWork && this.activities.length == 2) {
          for (let v of this.activities[1].children) {
            if (this.myWork == v.handler.id && !v.ended) {
              activityId = v.id
              break;
            }
          }
        } else if (this.activities.length == 1) {
          activityId = this.activities[0].id
        } else if (this.activities.length == 3) {
          activityId = this.activities[2].id
        }

        this.ajaxData({
          type: 'post',
          url : '/workflow/endActivity',
          data: {
            applyId   : this.applyId,
            activityId: activityId,
            result    : action
          }
        }, (res, all) => {
          if (all.code == 0) {
            this.$Message.info('提交成功');
            this.$emit('componentConEditPs')
            this.myRequisition(activityId);
            window.location.reload()
          }
        })
      },

      findExaminRecord(id) {
        this.addMeetListId = id;
        this.readProcessRecordActive = !0
      },
      addMeetList(){
        let applyId = this.addMeetListId
        let url = this._URL_v2 + '/workflow/workFlowExcelCreate'
        this.$http
          .post(
            url,
            {
              applyId: applyId
            },
            { emulateJSON: true }
          )
          .then(response => {
            if(response.body.message == null){
              this.$Message.error("操作过于频繁，请稍后再试！");
            } else {
              this.addMeetUrl = response.body.result.filePath;
              // window.open(this.addMeetUrl,"_blank")
              window.location.href= this.addMeetUrl
            }
          });
      },
      activityFormsChange1(v, formId, memo) {
        this.ajaxData({
          type: 'post',
          url : '/workflow/updateForm',
          data: {
            applyId: this.applyId,
            formId : formId,
            value  : v,
            memo   : memo
          }
        }, (res) => {
          if (this.processInstance) {
            this.closeReject()

            this.$Message.info('提交成功');
            this.$emit('componentConEditPs')
          }
        })
      },

      companyBlock() {
        this.$Modal.confirm({
          title  : '拉黑企业',
          content: '<p>确定拉黑？</p>',
          onOk   : () => {
            this.ajaxData({
              type: 'post',
              url : `/company/${this.editComponentData.companyId}/block`,
            }, (res, all) => {
              if (all.code == 0) {
                this.BLOCKCOMPANY = true;
                this.$Message.info('提交成功');
              }
            })
          }
        });
      },
      companyUnBlock() {
        this.ajaxData({
          type: 'post',
          url : `/company/${this.editComponentData.companyId}/unblock`
        }, (res, all) => {
          if (all.code == 0) {
            this.BLOCKCOMPANY = false
            this.$Message.info('提交成功');
          }
        })
      },
      SetScheduleTime() {
        if (this.scheduleContactValue) {
          this.editApplyStatus({
            data  : {
              appointDate: this.appointDateValue ? Number(this.appointDateValue) : '',
              appointUser: this.scheduleContactValue
            },
            action: 'appoint'
          })
        }
      },

      howDays(star, end) {
        let num = parseInt(Math.abs((star - end)) / (1000 * 60 * 60 * 24))
        return num < 1 ? '1天' : num + '天'
      },
      beforeUpload(file) {
        let files    = this.myActivity.files,
            fileName = file.name;
        let has      = files.find((v, k) => v.fileName == fileName)
        if (has) {
          this.$Notice.error({
            title: '错误',
            desc : '文件重复'
          });
          return false
        }
      },
      uploadFiles(response, file, fileList) {
        this.$emit('componentConEditPs')
      },
      filesType(type) {
        return type == 'xlsx' ? 'excel' : type == 'pdf' ? 'pdf' : type == 'docx' ? 'docx' : 'xxxx'
      },
      deleteFile(id) {
        this.ajaxData({
          type: 'post',
          url : '/workflow/deleteFile',
          data: {
            fileId: id
          }
        }, (res) => {
          this.$Message.info('提交成功');
          this.$emit('componentConEditPs')
        })
      },
      refreshProcess(id) {
        this.ajaxData({
          type: 'post',
          url : '/workflow/resetActivity',
          data: {
            applyId   : this.applyId,
            activityId: id
          }
        }, (res) => {
          this.$Message.info('提交成功');
          this.$emit('componentConEditPs')
        })
      },
      btnRefresh(ended) {
        if (this.isAdmin && ended) {
          if (this.activities.length == 3 && this.activities[2].ended) {
            return false
          } else {
            return true
          }
        } else {
          return false
        }
      },
      myRequisition(actId){
        if(actId){
          actId = actId
        } else {
          let obj = null
          if (this.activities.length == 2) {
            for (let v of this.activities[1].children) {
              if (v.handler.id == this.getPosition.id && !v.ended) {
                obj = v
                break;
              }
            }
          }
          if (this.editComponentData.applyStatus == 49) {
            obj = null
          }
          actId = obj.id
        }
        let activityId = actId
        let requisitionObj = null
        let policyId = this.editComponentData.policyId
        let url = this._URL_v2 + '/workflow/getFormTemplate'
        this.$http.post(url,{
          activityId: activityId,
            policyId:policyId
        },{emulateJSON: true}).then(res=>{
          if(res.body.code == 0){
            this.requisitionObj = res.body.result
          } else {
            this.requisitionObj = null
          }
          
        })
        // this.ajaxData({
        //   type:'post',
        //   url:'/workflow/getFormTemplate',
        //   data:{
        //     activityId: activityId,
        //     policyId:policyId
        //   }
        // },res=>{
        //   if(res != null){
        //     this.requisitionObj = res
        //     console.log(this.requisitionObj)
        //   } else {
        //     this.requisitionObj = null
        //   }
        // })
      }
    },
    mounted() {
      this.myRequisition()
    },
    created() {
      if (this.isAppoint && !this.activities.length) {
        this.getScheduleContactList()
      }
      if (this.appointmentMsg) {
        this.scheduleContactValue = this.appointmentMsg.governmentContact.id
        this.appointDateValue     = new Date(this.appointmentMsg.appointDate)
      }
      
    }
  }
</script>
